package models

import (
	"time"
)

type Model struct {
	Id               string          `orm:"pk"`
	RowId            string          `orm:"column(row_id)"`
	ProjectVersionId *ProjectVersion `orm:"column(project_version_id);rel(fk)"`
	Deleted          int32           `orm:"column(deleted)"`
	Name             string
	Shared           int32   `orm:"column(shared)"`
	FolderId         *Folder `orm:"column(folder_id);rel(fk)"`

	CreateTime     time.Time `orm:"column(create_time);type(datetime)"`
	CreateBy       string    `orm:"column(create_by)"`
	LastUpdateBy   string    `orm:"column(last_update_by)"`
	LastUpdateTime time.Time `orm:"column(last_update_time);type(datetime)"`

	ModelEntitys []*ModelEntity `orm:"reverse(many)"` // fk 的反向关系
}
type ModelEntity struct {
	Id      string `orm:"pk"`
	ModelId *Model `orm:"column(model_id);rel(fk)"`

	Name string

	Description string `orm:"column(description);type(longtext)"`

	CreateTime     time.Time `orm:"column(create_time);type(datetime)"`
	CreateBy       string    `orm:"column(create_by)"`
	LastUpdateBy   string    `orm:"column(last_update_by)"`
	LastUpdateTime time.Time `orm:"column(last_update_time);type(datetime)"`

	ModelAttributes []*ModelAttribute `orm:"reverse(many)"` // fk 的反向关系
}

type ModelAttribute struct {
	Id             string       `orm:"pk"`
	EntityId       *ModelEntity `orm:"column(entity_id);rel(fk)"`
	AttributeOrder int32
	Name           string

	Description string `orm:"column(description);type(longtext)"`

	Type         string
	TypeEntityId string
	Pk           int32 `orm:"column(pk);type(smallint)"`

	CreateTime     time.Time `orm:"column(create_time);type(datetime)"`
	CreateBy       string    `orm:"column(create_by)"`
	LastUpdateBy   string    `orm:"column(last_update_by)"`
	LastUpdateTime time.Time `orm:"column(last_update_time);type(datetime)"`
}
